package com.kuangstudy.thread.demo3;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

/**
 * @author Losca
 * @date 2021/7/19 19:13
 * 模拟倒计时
 * 打印当前时间
 */
public class Sleep2 {
    public static void main(String[] args) {
//        tenDown();
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(new SimpleDateFormat("HH:mm:ss").format(new Date()));
        }

    }

    private static void tenDown() {
        int num = 10;
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(num--);
            if (num < 0){
                break;
            }
        }
    }
}
